package com.cloudwise.controller;

import com.cloudwise.entity.ReturnBean;

/**
 * @author:高杰领
 * @date:2022/1/20 9:47
 * @description:提供操作成功和失败方法
 * @version:1.0
 **/
public class BaseController {
    /**
     *
     * @param object
     * @param msg
     * @param count
     * @return com.cloudwise.entity.ReturnBean
     * @author 高冷
     * @description:操作成功返回方法
     * @date 2022/1/20 10:22
     */
    public ReturnBean success(Object object,String msg, Long... count) {
        ReturnBean returnBean = new ReturnBean();
        returnBean.setCode(0);
        returnBean.setMsg(msg);
        returnBean.setData(object);
        if (count != null && count.length > 0) {
            returnBean.setCount(count[0]);
        }
        return returnBean;
    }
    /**
     *
     * @param object
     * @param count
     * @return com.cloudwise.entity.ReturnBean
     * @author 高冷
     * @description:操作成功返回方法
     * @date 2022/1/20 10:22
     */
    public ReturnBean success(Object object, Long... count) {
        ReturnBean returnBean = new ReturnBean();
        returnBean.setCode(0);
        returnBean.setMsg("操作成功");
        returnBean.setData(object);
        if (count != null && count.length > 0) {
            returnBean.setCount(count[0]);
        }
        return returnBean;
    }
    /**
     *
     * @param object
     * @param msg
     * @return com.cloudwise.entity.ReturnBean
     * @author 高冷
     * @description:操作失败方法
     * @date 2022/1/20 9:52
     */
    public ReturnBean fail(Object object,String msg) {
        ReturnBean returnBean = new ReturnBean();
        returnBean.setCode(1);
        returnBean.setMsg(msg);
        returnBean.setData(object);
        return returnBean;
    }
    public ReturnBean fail(String msg){
        ReturnBean returnBean = new ReturnBean();
        returnBean.setCode(1);
        returnBean.setMsg(msg);
        return returnBean;
    }
    public ReturnBean fail(Object object,Long... count){
        ReturnBean returnBean = new ReturnBean();
        returnBean.setCode(1);
        returnBean.setMsg("操作失败");
        returnBean.setData(object);
        if (count != null && count.length > 0) {
            returnBean.setCount(count[0]);
        }
        return returnBean;
    }
}
